package com.hebeu.device.controller;


import com.hebeu.device.pojo.DUser;
import com.hebeu.device.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * 登录控制器
 * 样例
 */

@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/getUser")
    public DUser getUser(String userName, String password, HttpSession session){
        System.out.println(userName + ":" + password);
        //通过用户名密码查询用户信息
        DUser dUser = loginService.getDUser(userName, password);
        session.setAttribute("user", dUser);
        return dUser;
    }
}
